home *** CD-ROM | disk | FTP | other *** search
/ Exame Informatica 139 / Exame Informatica 139.iso / Revista / Flash / Uniform Server / diskw / home / admin / www / phpMyBackupPro / login.php < prev    next >
Encoding:
PHP Script  |  2005-07-14  |  5.1 KB  |  136 lines

  1. <?php
  2. /*
  3.  +--------------------------------------------------------------------------+
  4.  | phpMyBackupPro                                                           |
  5.  +--------------------------------------------------------------------------+
  6.  | Copyright (c) 2004-2005 by Dirk Randhahn                                 |
  7.  | http://www.phpMyBackupPro.net                                            |
  8.  | version information can be found in definitions.php.                     |
  9.  |                                                                          |
  10.  | This program is free software; you can redistribute it and/or            |
  11.  | modify it under the terms of the GNU General Public License              |
  12.  | as published by the Free Software Foundation; either version 2           |
  13.  | of the License, or (at your option) any later version.                   |
  14.  |                                                                          |
  15.  | This program is distributed in the hope that it will be useful,          |
  16.  | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
  17.  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
  18.  | GNU General Public License for more details.                             |
  19.  |                                                                          |
  20.  | You should have received a copy of the GNU General Public License        |
  21.  | along with this program; if not, write to the Free Software              |
  22.  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.|
  23.  +--------------------------------------------------------------------------+
  24. */
  25.  
  26. @session_start();
  27.  
  28. // get password and username
  29. require_once("definitions.php");
  30.  
  31. // login with http authentification
  32. if ($CONF['login']) {
  33.     if (!isset($_SERVER['PHP_AUTH_USER'])
  34.     || (isset($_GET["login"]) && !($_SERVER['PHP_AUTH_USER']==$CONF['sql_user'] && $_SERVER['PHP_AUTH_PW']==$CONF['sql_passwd']))
  35.     || (isset($_GET["logout"]) && $_SERVER['PHP_AUTH_PW']==$CONF['sql_passwd'])) {
  36.         header("WWW-Authenticate: Basic realm=\"phpMyBackupPro\"");
  37.         header("HTTP/1.0 401 Unauthorized");
  38.         echo LI_NOT_LOGED_OUT;
  39.         echo ": <a href=\"index.php?logout=TRUE\">".F_LOGOUT."</a><br>";
  40.         echo LI_MSG.": <a href=\"index.php?login=TRUE\">".LI_LOGIN."</a>";
  41.         exit;
  42.     } else if ($_SERVER['PHP_AUTH_PW']!=$CONF['sql_passwd']) {
  43.         echo LI_LOGED_OUT."<br>\n".LI_MSG;
  44.         echo ": <a href=\"index.php?login=TRUE\">".LI_LOGIN."</a>";
  45.         unset($_SESSION['PMBP_VERSION']);
  46.         unset($_SESSION['LOGGED_IN']);
  47.         unset($_SESSION['sql_host_org']);
  48.         unset($_SESSION['sql_user_org']);
  49.         unset($_SESSION['sql_passwd_org']);
  50.         @session_destroy();
  51.         exit;
  52.     }
  53.     
  54.     // login with html authentification
  55. } else {
  56.  
  57.     // disable login functions if $CONF['no_login'] is true
  58.     if ($CONF['no_login']!="1") {
  59.         if (!isset($_SESSION['LOGGED_IN'])) $_SESSION['LOGGED_IN']=FALSE;    
  60.  
  61.         // not logged in
  62.         if (!$_SESSION['LOGGED_IN']) {
  63.             if (!isset($_POST['password'])) $_POST['password']=FALSE;        
  64.  
  65.             // login failed
  66.             if ($CONF['sql_user'] AND $CONF['sql_passwd'] AND ($_POST['password']!=$CONF['sql_passwd'] OR $_POST['username']!=$CONF['sql_user'])){
  67.  
  68.                 // print login form
  69.                 ?>
  70. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  71.    "http://www.w3.org/TR/html4/loose.dtd">
  72. <html<?php echo ARABIC_HTML;?>>
  73. <head>
  74. <meta http-equiv="Content-Type" content="text/html;charset=<?php echo BD_CHARSET_HTML;?>">
  75. <link rel="stylesheet" href="<?php echo PMBP_STYLESHEET_DIR.$CONF['stylesheet'];?>.css" type="text/css">
  76. <title>phpMyBackupPro</title>
  77. </head>
  78. <body onLoad="document.login.username.focus()">
  79. <form name="login" action="" method="POST">
  80. <table width="400">
  81.   <tr>
  82.     <th colspan="2" class="active">
  83. <?php
  84. echo PMBP_image_tag("logo.png","phpMyBackupPro PMBP_WEBSITE",PMBP_WEBSITE);
  85. ?>
  86.     </th>
  87.   </tr>
  88.   <tr>
  89.     <td colspan="2"><?php echo LI_MSG; ?>:</td>
  90.   </tr>
  91.   <tr>
  92.     <td><?php echo LI_USER; ?>:</td>
  93.     <td><input type="text" name="username"></td>
  94.   </tr>
  95.   <tr>
  96.     <td><?php echo LI_PASSWD; ?>:</td>
  97.     <td><input type="password" name="password"></td>
  98.   </tr>
  99.   <tr>
  100.     <td colspan="2"><input type="submit" name="login" value="<?php echo LI_LOGIN; ?>" class="button"></td>
  101.   </tr>
  102. </table>
  103. </form>
  104. </body>
  105. </html>
  106.             <?php
  107.             $CONF="";
  108.             
  109.             // break loading page if not logged in
  110.             exit;
  111.         
  112.         // save username in session if logged in
  113.         } else {
  114.             $_SESSION['LOGGED_IN']=TRUE;
  115.             $_GET['login']=TRUE;
  116.         }
  117.     }
  118.  
  119.     if (isset($_GET['logout'])) {
  120.         @session_start();
  121.         unset($_SESSION['PMBP_VERSION']);
  122.         unset($_SESSION['LOGGED_IN']);
  123.         unset($_SESSION['sql_host_org']);
  124.         unset($_SESSION['sql_user_org']);
  125.         unset($_SESSION['sql_passwd_org']);
  126.         header("Location: index.php");
  127.         exit;
  128.     }
  129.  
  130.     // when login functions is disabled
  131.     } else {
  132.         $_SESSION['LOGGED_IN']="Login deactivated!";
  133.     }
  134. } // end type of auth
  135. ?>
  136.